package servlets;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import myJDBC.lowLevel.AttrTypeDef;

/**
 * Servlet implementation class SrvlCreateListValues
 */
@WebServlet("/SrvlCreateListValues")
public class SrvlCreateListValues extends HttpServlet {
	private static final long serialVersionUID = 1L;
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String name= request.getParameter("name");
		String attrId=request.getParameter("attrType");
		String[] values =request.getParameter("values").split("\r\n");
		try {
			AttrTypeDef.createAttrTypeDef(Integer.parseInt(attrId), name, values);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		response.sendRedirect("privateOffice");
	}

}
